// pages/my-center/my-center.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    avatarUrl:'',
    nickName:'',
    liveFlag: false,
    bookingFlag: false,
    centerFlag: true,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    wx.getUserInfo({
      success: function (res) {
        var userInfo = res.userInfo
        var avatarUrl = userInfo.avatarUrl
        var nickName = userInfo.nickName
        that.setData({
          avatarUrl: avatarUrl,
          nickName: nickName
        })
      }
    })
  },
  _changeBar: function (e) {
    // tabber 切换
    console.log(e)
    var that = this;
    var _type = e.detail.type;
    switch (_type) {
      case 'booking':
        that.setData({
          liveFlag: false,
          bookingFlag: true,
          centerFlag: false,
        });
        wx.redirectTo({
          url: "../../pages/newindex/newindex"
        });
        break;
      case 'live':
        that.setData({
          liveFlag: true,
          bookingFlag: false,
          centerFlag: false,
        });
        wx.redirectTo({
          url: "../../pages/live-list/live-list"
        });
        break;
      case 'center':
        that.setData({
          liveFlag: false,
          bookingFlag: false,
          centerFlag: true,
        });
        wx.redirectTo({
          url: "../../pages/my-center/my-center"
        })
        break;
    }
  },

  turnTo:function(){
    wx.navigateTo({
      url: '../../pages/booking-history/booking-history'
    })
  },

  recent:function(){
    wx.navigateTo({
      url: '../../pages/recent-watch/recent-watch'
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})